﻿using GalaSoft.MvvmLight;
using KPI.Entity;
using KPI.UIBase;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KPIClient.Views
{
    public class ViewEditQuestionNaireModel : ViewModelBase
    {

        public ViewEditQuestionNaireModel()
        {
            ListQtType.Add(new IntStringData { Key = -1, Value = "全部" });
            ListQtType.Add(new IntStringData { Key = ((int)EnumQtType.SingleSelect), Value = "单选题" });
            ListQtType.Add(new IntStringData { Key = ((int)EnumQtType.MutilSelect), Value = "多选题" });
            ListQtType.Add(new IntStringData { Key = ((int)EnumQtType.TrueFalse), Value = "判断题" });
            ListQtType.Add(new IntStringData { Key = ((int)EnumQtType.ShortAnswer), Value = "简答题" });
        }
        private ObservableCollection<IntStringData> _ListQtType = new ObservableCollection<IntStringData>();
        public ObservableCollection<IntStringData> ListQtType { get { return _ListQtType; } set { Set("ListQtType", ref _ListQtType, value); } }

        private IntStringData _SelectedQtType;
        public IntStringData SelectedQtType { get => _SelectedQtType; set => Set("SelectedQtType", ref _SelectedQtType, value); }

        private string _SearchQtName;
        public string SearchQtName { get => _SearchQtName; set => Set("SearchQtName", ref _SearchQtName, value); }



        private string _Title;
        public string Title { get => _Title; set => Set("Title", ref _Title, value); }

        private string _EditTitle;
        public string EditTitle { get => _EditTitle; set => Set("EditTitle", ref _EditTitle, value); }

        private string _Comment;
        public string Comment { get => _Comment; set => Set("Comment", ref _Comment, value); }

        private ObservableCollection<QuestionInfoModel> _ListQuestionBank = new ObservableCollection<QuestionInfoModel>();
        public ObservableCollection<QuestionInfoModel> ListQuestionBank { get { return _ListQuestionBank; } set { Set("ListQuestionBank", ref _ListQuestionBank, value); } }

        private ObservableCollection<QuestionInfoModel> _ListQuestionInExam = new ObservableCollection<QuestionInfoModel>();
        public ObservableCollection<QuestionInfoModel> ListQuestionInExam { get { return _ListQuestionInExam; } set { Set("ListQuestionInExam", ref _ListQuestionInExam, value); } }

        public ExamRecordVO Data { get; private set; }

        public virtual void FromData(ExamRecordVO data)
        {
            this.Data = data;
            if (data == null)
                return;
            Title = data.title;
            data.listHistoryQuestion?.ForEach(x =>
            {
                QuestionInfoModel model = new QuestionInfoModel();
                model.FromData(x);
                model.Index = ListQuestionInExam.Count + 1;
                ListQuestionInExam.Add(model);
            });
        }
    }
}
